<template>
  <!-- 忘记密码 -->
  <div class="main">
    <div class="bottom">
      <i class="el-icon-back"></i>
      <div class="back" @click="backToIndex()">返回首页</div>
    </div>
    <div class="box dowebok">
      <div class="form-container sign-in-container">
        <div class="form">
          <h1>忘记密码？输入邮箱可通过邮件找回</h1>
          <input type="text" placeholder="邮箱号" v-model="mail" />
          <button @click="forgetPwdBtn">找回密码</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { forgetpwd } from "./../../api/user"
export default {
  name: "forgetpwd",
  data() {
    return {
      mail: "",
    };
  },
  mounted: function () { },
  methods: {
    backToIndex: function () {
      this.$router.back();
    },
    forgetPwdBtn: function () {
      console.log("忘记密码", this.mail);
      if (this.mail == "") {
        this.$message.error("您还没有输入邮箱号码");
      } else {
        forgetpwd({
          email: this.mail
        })
          .then(res => {
            if (res.rescode == 200) {
              this.open1(`账号${this.mail}的密码已发送至您的邮箱，请注意查收`, 'success');
              this.$router.back();
              this.mail = null;
            } else if (res.rescode == 500) {
              this.open1(`账号${this.mail}不存在`, 'error')
            } else if (res.rescode == 400) {
              this.open1(`账号${this.mail} 邮件发送错误`, 'error')
            }
          })
          .catch(err => {
          })
      }
    }
  },
};
</script>


<style lang="less" scoped>
.main {
  font-family: "Montserrat", sans-serif;
  // display: flex;
  // justify-content: center;
  // padding-top: 100px;
  // box-sizing: border-box;
}

h1 {
  font-weight: bold;
  margin: 0;
}

.dowebok {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  position: relative;
  overflow: hidden;
  margin: 0 auto;
  margin-top: 100px;
  width: 600px;
  max-width: 100%;
  min-height: 200px;
  padding: 40px 100px;
  box-sizing: border-box;
}


.bottom {
  display: flex;
  text-align: center;
}

.el-icon-back {
  font-size: 1.4em;
  font-weight: bold;
  padding-top: 2px;
  padding-left: 10px;
}

.el-button {
  margin-bottom: 100px;
}

.back {
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  padding-bottom: 20px;
}


.form-container .form {
  background: #fff;
  display: flex;
  flex-direction: column;
  padding: 0 50px;
  height: 100%;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.form-container input {
  background: #eee;
  border: none;
  padding: 12px 15px;
  margin: 20px 0;
  width: 100%;
  outline: none;
}

button {
  border-radius: 20px;
  border: 1px solid #5a67fc;
  background: #5a67fc;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  padding: 12px 45px;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: transform 80ms ease-in;
  cursor: pointer;
}

.checkCode_btn {
  height: 40px;
  padding: 0;
  width: 100px;
  margin-top: 8px;
}

button:active {
  transform: scale(0.95);
}

button:focus {
  outline: none;
}

button.ghost {
  background: transparent;
  border-color: #fff;
}
</style>